<template>
	<view>
		<u-loading-page :loading="loadding" loading-mode="semicircle" loading-text="Hello Pro"></u-loading-page>
		<view class="data_box" v-if="!loadding">
			<view v-if="version == '5.0' && bonus.length>0" class="data_list no-p-t">
				<view class="items" v-for="(item, index) in bonus" :key="index">
					<view class="titles">
						<view class="">
							{{item.code}}
						</view>
						<view class="condition">
							{{item.condi}}
						</view>
					</view>
					<view v-if="item.monData && item.monData.length > 0" v-for="(items, indexs) in item.monData"
						class="share-total" :class="indexs==0?'bottom_line':''" :key="indexs">
						<view class="moneys">
							<text class="month">{{items.timesNick}}</text>
							<text>分红：</text>
							<text class="m-total">{{items.money}}</text>
						</view>
						<view class="standard" @click="detail(items.levs, items.times)">
							<text>达标</text>
							<text class="numbers">{{items.nums}}</text>
							<text>人</text>
							<text v-if="items.nums > 0" class="detail">
								详情
							</text>
						</view>
					</view>
				</view>
			</view>
			<u-empty v-else mode="list" icon="/static/Empty/data_null.png">
			</u-empty>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loadding: true,
				bonus: [],
				version: '',
				versionHref: 'version1',
				// menu: []
			}
		},
		onLoad() {
			this.version = uni.getStorageSync('version')
			if (this.version == '5.0') {
				this._list5()
				// this._menu5()
				this.versionHref = 'version5'
				uni.setTabBarItem({
					index: 1,
					visible: true
				})
			} else {
				this._list()
				// this._menu()
				this.versionHref = 'version1'
				uni.setTabBarItem({
					index: 1,
					visible: false
				})
			}
		},
		methods: {
			//页面数据
			async _list() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'Bonus/stands_list',
					// data: {},
					header: {
						'token': userinfo.token
					},
				});
				this.loadding = false
				this.bonus = res.data
			},
			async _list5() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'Bonus/stands_list',
					// data: {},
					header: {
						'token': userinfo.token
					},
				});
				this.loadding = false
				this.bonus = res.data
			},
			tranDataInfo(e) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/data/transaction/data_detailed?type=' + e
				})
			},
			activeDataInfo(e) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/data/active/data_detailed?type=' + e
				})
			},
			//团队
			team(type) {
				uni.navigateTo({
					url: '/pages/' + this.versionHref + '/data/team/team_info?type=' + type
				})
			},
			// 菜单展示
			async _menu() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp({
					url: 'menu/getData',
					// data: {},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					this.menu = res.data
				}
			},
			async _menu5() {
				const userinfo = uni.getStorageSync('userinfo');
				const {
					data: res
				} = await this.$myHttp5({
					url: 'menu/getData',
					// data: {},
					header: {
						'token': userinfo.token
					},
				});
				if (res.code == 1) {
					this.menu = res.data
				}
			},
			// 详情
			detail(levs, times) {
				uni.navigateTo({
					url: '/pages/bonus/detail?levs=' + levs + '&times=' + times
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.data_box {
		padding: 30rpx;

		.data_list {
			box-sizing: border-box;
			margin-bottom: 30rpx;
			border-radius: 15rpx;
			box-shadow: 7px 0px 30px -18px #888888;
			padding-bottom: 20rpx;

			.items {
				margin-bottom: 30rpx;
				border-radius: 15rpx;
				box-shadow: 7px 0px 30px -18px #888888;

				.titles {
					margin: 0 20rpx;
					padding: 20rpx 0;
					border-bottom: 1px solid #f4f4f5;
					display: flex;
					justify-content: space-between;
					font-weight: bold;
				}

				.share-total {
					margin: 30rpx 20rpx;
					padding-bottom: 30rpx;
					display: flex;
					justify-content: space-between;

					text {
						margin-top: 0rpx;
						font-size: 28rpx;
						color: #333;
					}

					.moneys {
						width: 65%;
						font-size: 24rpx;

						.m-total {
							font-weight: bold;
						}

						.month {
							padding-right: 20rpx;
							font-weight: bold;
						}
					}

					.standard {
						width: 35%;
						display: flex;
						font-size: 24rpx;
						justify-content: flex-end;

						.numbers {
							padding: 0 10rpx;
							font-weight: bold;
							color: #fa3534;
						}

						.detail {
							font-size: 24rpx;
							padding-left: 10rpx;
							padding-top: 2rpx;
							color: #2f9fff;
						}
					}
				}
			}
		}
	}

	.bottom_line {
		border-bottom: 1px dashed #eee;
	}

	.no-p-t {
		padding-bottom: 0rpx !important;
	}

	.no-b-b {
		border-bottom: none !important;
	}
</style>